﻿@using AC.Service.DTO.LiCai
@using AC.Util
@model wychuan2.com.Areas.admin.Models.LiCai.BillModel

<div class="row">
    <div class="col-lg-12">
        <div class="alert alert-info alert-dismissable">
            <button aria-hidden="true" data-dismiss="alert" class="close" type="button">×</button>
            <a href="/admin/licai/bill" class="btn btn-white">详细记账</a>
            <a href="/admin/licai/details" class="btn btn-white">查看明细</a>
        </div>
    </div>
</div>
@if (Model.Templates != null)
{
    string templates = JsonHelper.ToJson(Model.Templates);
    <script type="text/javascript">
        var templates = @Html.Raw(templates);
    </script>
    for (int i = 0; i < Model.Templates.Count; i++)
    {
        BillTemplateDTO template = Model.Templates[i];
        if (i%2 == 0)
        {
            @Html.Raw("<div class=\"row\">")
        }
        <div class="col-lg-6">
            <div class="bill">
                <input type="hidden" value="@template.ID" name="Id" />
                <span>@template.AccountDesc - <small>@template.Remark</small></span>
                <h4>@template.Name</h4>
                <small>@template.FirstCategory - @template.SecondCategory</small>
                <a class="a2"><i class="fa fa-edit"></i>编辑</a>
                <a class="a1"><i class="fa fa-trash-o"></i>删除</a>
            </div>
        </div>
        if (i%2 != 0)
        {
            @Html.Raw("</div>")
        }
    }
    <script type="text/javascript">
        
        $(".bill").each(function(index, bill) {
            var id = $(bill).find("[name=Id]").val();
            var current = $.grep(templates, function(item, index) {
                return item.ID == id;
            });
            if (current.length > 0) {
                $(bill).data("template", current[0]);
            }
        })
    </script>
}
